package view.commands;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import util.commands.FileCommand;
import view.Frame;

public class Upload extends FileCommand<Frame>
{

    public Upload()
    {
        super(JFileChooser.OPEN_DIALOG);
    }

    @Override
    public void execute(Frame target)
    {
        try
        {
            BufferedImage image = ImageIO.read(new File(getFileName()));
            target.getCanvas().getPixmap().setImageBackground(image);
        }
        catch (IOException e)
        {
            // TODO: do something
        }

    }

}
